package com.k2data.k2app.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.stereotype.Component;

/**
 * @author lidong9144@163.com 17-4-26.
 */
@Component
public class AppStoppedEvent implements ApplicationListener<ContextStoppedEvent> {

    private final KafkaService kafkaService;

    @Autowired
    public AppStoppedEvent(KafkaService kafkaService) {
        this.kafkaService = kafkaService;
    }

    @Override
    public void onApplicationEvent(ContextStoppedEvent event) {
        kafkaService.shutdown();
    }

}
